package com.ssy.lingxi.platform.manage.serviceimpl.mobile;

import com.ssy.lingxi.common.response.ResponseCode;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.constant.CommonBooleanEnum;
import com.ssy.lingxi.platform.manage.entity.content.MemberColumn;
import com.ssy.lingxi.platform.manage.repository.MemberColumnRepository;
import com.ssy.lingxi.platform.manage.service.mobile.IMemberColumnMobileService;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * mobile - 自营商家 - 栏目 - 业务实现层
 * @author fhj
 * @version 2.0.0
 * @date 2021/10/25
 */
@Service
public class MemberColumnMobileServiceImpl implements IMemberColumnMobileService {

    @Resource
    private MemberColumnRepository memberColumnRepository;

    @Override
    public Wrapper<List<MemberColumn>> all(Long memberId, Long roleId) {
        //校验
        if(memberId == null || roleId == null) {
            return Wrapper.fail(ResponseCode.PT_PARAMETER_VERIFICATION_FAILED);
        }
        return Wrapper.success(
                memberColumnRepository.findAllByMemberIdAndMemberRoleIdAndStatus(
                        memberId,
                        roleId,
                        CommonBooleanEnum.YES.getCode(),
                        Sort.by("id")
                )
        );
    }
}
